<template>
	<div class="wrapper" ref="wrapper">
		<div class="content">
			<slot></slot>
		</div>
	</div>
</template>

<script>
	import BSscroll from 'better-scroll'
	import Pullup from '@better-scroll/pull-up'
	 BSscroll.use(Pullup)
	export default {
		data() {
			return{
				scroll:null
			}
		},
		props:{
			probeType:{
				type:Number,
				default:0
			},
			pullUpload:{
				type:Boolean,
				default:false
			}
		},
		mounted() {
			this.scroll=new BSscroll(this.$refs.wrapper,{
				probeType:3,
				observeDOM:true,
				click:true,
				probeType:this.probeType,
				pullUpLoad: true,
				observeImage:true
				
			})
			this.scroll.on('scroll',(position)=>{
				this.$emit('scroll',position)
			})
			this.scroll.on('pullingUp',()=>{
				this.$emit('pullingUp')
			})
			this.scroll.refresh()//加载完后刷新一次
			//bug 计算出来的高度小于实际内容的高度 导致无法滑动
			
		},
		methods:{
			scrollTo(x,y,time=300){
				this.scroll.scrollTo(x,y,time)
			},
			finishPullUp(){
				this.scroll.finishPullUp()
			},
			refresh(){
				this.scroll.refresh()
			},
			getScrollY(){
				return this.scroll ? this.scroll.y : 0
			}
		}
	}
</script>

<style>
</style>
